<template>
  <div class="home-page-AMS">
    <div class="eqp-status">
      <div class="eqp-item eqp-alarm">
        <div class="item-status">
          <span>报警设备</span>
          <span class="item-num">{{ alarmNums.alarmEqpCount }}</span>
        </div>
      </div>
      <div class="eqp-item eqp-normal">
        <div class="item-status">
          <span>正常设备</span>
          <span class="item-num">{{ alarmNums.normalEqpCount }}</span>
        </div>
      </div>
      <div class="eqp-item alarm-today">
        <div class="item-status">
          <span>今日报警</span>
          <span class="item-num">{{ alarmNums.todayAlarmCount }}</span>
        </div>
      </div>
    </div>
    <div class="fifteen-trend">
      <span :style="{fontSize: '20px'}">近15天报警趋势</span>
      <fifteenEcharts :fifteen-date="fifteenDate" />
    </div>
    <div class="top-trend">
      <div class="hot-item hot-alarm">
        <span class="hot-title">30天报警设备Top10</span>
        <div class="alarm-eqp">
          <eqpAlarmEcharts :alarm-eqp-date="alarmEqpDate"/>
        </div>
      </div>
      <div :style="{width: '30px'}"/>
      <div class="hot-item hot-code">
        <span class="hot-title">30天报警代码Top10</span>
        <div class="alarm-code">
          <eqpCodeEcharts :alarm-code-date="alarmCodeDate"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import fifteenEcharts from './components/fifteenEcharts.vue'
import eqpAlarmEcharts from './components/eqpAlarmEcharts.vue'
import eqpCodeEcharts from './components/eqpCodeEcharts.vue'
import { initCharts } from '@/api/alarm/homeCharts'
export default {
  name: 'HomePageAMS',
  components: { fifteenEcharts, eqpAlarmEcharts, eqpCodeEcharts },
  data() {
    return {
      alarmNums: {
        alarmEqpCount: 0,
        normalEqpCount: 0,
        todayAlarmCount: 0
      },
      fifteenDate: [],
      alarmEqpDate: [],
      alarmCodeDate: []
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      initCharts().then(res => {
        const { alarmCodes, alarmDates, alarmEqps, ...obj } = res.data
        this.alarmNums = obj
        this.fifteenDate = alarmDates
        this.alarmEqpDate = alarmEqps
        this.alarmCodeDate = alarmCodes
      })
    }
  }
}
</script>

<style scoped lang="scss">
.home-page-AMS{
  width: 100%;
  padding: 20px 20px 120px 20px;
  background-color: #fff;
  .eqp-status{
    display: flex;
    .eqp-item{
      width: 240px;
      height: 120px;
      margin-right: 20px;
      display: flex;
      justify-content: flex-end;
      .item-status{
        width: 70%;
        height: 100%;
        font-size: 20px;
        color: #fff;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        word-break: break-all;
        background-color: #f5f5f531;
        .item-num{
          padding-top: 10px;
          font-size: 40px;
        }
      }
    }
    .eqp-alarm{
      background-color: rgb(245,108,108);
    }
    .eqp-normal{
      background-color: rgb(103,194,58);
    }
    .alarm-today{
      background-color: rgb(230,162,60);
    }
  }
  .fifteen-trend{
    width: 100%;
    height: 400px;
    padding-top: 20px;
  }
  .top-trend{
    width: 100%;
    display: flex;
    justify-content: space-between;
    // padding-top: 10px;
    .hot-item{
      // width: 30%;
      flex: 1;
      height: 300px;
      .hot-title{
        font-size: 20px;
        display: inline-block;
        padding: 20px 0;
      }
      .alarm-eqp{
        border: 1px solid #ccc;
        width: 100%;
        height: 100%;
      }
    }
    .hot-code{
      // width: 50%;
      flex: 1;
      height: 300px;
      .alarm-code{
        border: 1px solid #ccc;
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
